package model.socio;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import model.banco.ConexaoFactory;
import model.pessoa.Socio;

public class SocioDAO {

	public void salvar(Socio socio) {
		Connection con = ConexaoFactory.getInstance().getConexao();

		String sql = "insert into clube.pessoa (nome, endereco, telefone, sexo, cpf, rg, data_nascimento, qtd_aula, qtd_evento, parcial, tipo_pessoa) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
		PreparedStatement statement = null;
		try {
			statement = con.prepareStatement(sql);
			statement.setString(1, socio.getNome());
			statement.setString(2, socio.getEndereco());
			statement.setString(3, socio.getTelefone());
			statement.setString(4, socio.getSexo().name());
			statement.setString(5, socio.getCPF());
			statement.setString(6, socio.getRG());
			statement.setString(7, socio.getDataNascimento());
			statement.setInt(8, socio.getQtdAula());
			statement.setInt(9, socio.getQtdEvento());
			statement.setBoolean(10, socio.isParcial());
			statement.setString(11, "socio");
			statement.execute();
		} catch (SQLException e) {
			e.printStackTrace();
		}

	}

	// public List<Socio> pesquisar(String nome) {
	// List<Socio> socios = new ArrayList<Socio>();
	// String sql =
	// "select * from clube.pessoa where nome like ? and tipo_pessoa like 'socio'";
	//
	// PreparedStatement statement = null;
	// ResultSet result = null;
	//
	// try {
	// statement = ConexaoFactory.getInstance().getConexao()
	// .prepareStatement(sql);
	// result = statement.executeQuery();
	//
	// while (result.next()) {
	// Aluno a = new Aluno();
	// Curso c = new Curso();
	// c.setNome(result.getString("descricao"));
	// a.setMatricula(result.getString("matricula"));
	// a.setNome(result.getString("nome"));
	// a.setTipo(result.getString("tipo"));
	// a.setCurso(c);
	// socios.add(a);
	// }
	// result.close();
	// statement.close();
	// return socios;
	// } catch (SQLException e) {
	// e.printStackTrace();
	// }
	//
	// return null;
	// }
}
